package net.siufung.market.base.log.login.event.consumer;

import com.google.common.eventbus.Subscribe;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.siufung.core.event.IEventConsumer;
import net.siufung.core.utils.CopyUtil;
import net.siufung.market.base.log.login.event.dto.LoginLogSaveDto;
import net.siufung.market.base.log.login.mapper.entity.LoginLog;
import net.siufung.market.base.log.login.service.ILoginLogService;

/**
 * @author 陈建峰
 * @date 2023/2/15 10:13 AM
 * @since V1.0.0
 */
@Slf4j
@AllArgsConstructor
public class LoginLogRecordConsumer implements IEventConsumer<LoginLogSaveDto> {

    private final ILoginLogService logService;

    @Subscribe
    @Override
    public void consumer(LoginLogSaveDto logSaveDto) {
        LoginLog loginLog = new LoginLog();
        CopyUtil.copyProperties(logSaveDto, loginLog);
        logService.save(loginLog);
    }
}
